<?php

/**
 * This is the model class for table "adm_group_menu".
 *
 * The followings are the available columns in table 'adm_group_menu':
 * @property string $id_adm_group
 * @property string $id_adm_menu
 * @property string $view
 * @property string $edit
 * @property string $delete
 * @property string $approve
 *
 * The followings are the available model relations:
 * @property AdmGroup $idAdmGroup
 * @property AdmMenu $idAdmMenu
 */
class AdmGroupMenu extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AdmGroupMenu the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'adm_group_menu';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_adm_group, id_adm_menu', 'required'),
			array('id_adm_group, id_adm_menu', 'length', 'max'=>19),
			array('view, edit, delete, approve', 'length', 'max'=>1),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_adm_group, id_adm_menu, view, edit, delete, approve', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idAdmGroup' => array(self::BELONGS_TO, 'AdmGroup', 'id_adm_group'),
			'idAdmMenu' => array(self::BELONGS_TO, 'AdmMenu', 'id_adm_menu'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_adm_group' => 'Id Adm Group',
			'id_adm_menu' => 'Id Adm Menu',
			'view' => 'View',
			'edit' => 'Edit',
			'delete' => 'Delete',
			'approve' => 'Approve',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_adm_group',$this->id_adm_group,true);
		$criteria->compare('id_adm_menu',$this->id_adm_menu,true);
		$criteria->compare('view',$this->view,true);
		$criteria->compare('edit',$this->edit,true);
		$criteria->compare('delete',$this->delete,true);
		$criteria->compare('approve',$this->approve,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}